﻿<cfcomponent>
<cfscript>
DB = 'chinalaohu';
dbt = 'auction_userwon';
</cfscript>

<!---拍品是否加入交易单--->
<cffunction name="chacktopaid" access="public" returntype="query">
	<cfquery datasource="#DB#" name="chacktopaid">
  SELECT aid,uid
  FROM
  #dbt#
  WHERE aid = #aid#
  </cfquery>
  
  <cfreturn chacktopaid>

</cffunction>

<!---物流查询用--->
<cffunction name="logistic" access="public" returntype="query">
<cfquery datasource="#DB#" name="logistic">
SELECT
auction_userwon.aid,
auction.acode,
auction_userwonpaid.shipment,
auction_userwonpaid.ship_no,
insure_fee,
auction_userwon.auction,
auction_userwon.acode,
auction_userwon.endtime,
auction_userwon.bid,
auction_userwon.bid_fee,
auction_userwon.bid_amount
FROM
auction_userwon
INNER JOIN auction_userwonpaid ON auction_userwonpaid.paidID = auction_userwon.paidID
inner join auction on auction_userwon.aid=auction.aid
WHERE
auction_userwon.aid = #aid# and  auction_userwon.pay_status=2
</cfquery>
<cfreturn logistic>
</cffunction>



<cffunction name="orderitemlist" access="public" returntype="query">

<cfquery name="orderitemlist" datasource="#DB#">
SELECT
*
FROM
auction_userwon
WHERE
paidid=#paidid#
</cfquery>

<cfreturn orderitemlist>
</cffunction>

<!---已支付拍品--->
<cffunction access="public" name="paidauctionlist" returntype="query">
<cfquery datasource="#DB#" name="paidauctionlist">


select d.aid,d.acode,f.img_waterfall,d.auction,b.prevtime,b.starttime,b.endtime,d.bid_amount AS lastprice,b.atag
 from auction_userlastbid  a  left outer join auction b on a.aid=b.aid  INNER JOIN auction_gallery f ON f.agid = b.agid left outer join auction_special c on b.asid=c.asid  left outer join auction_userwon d on a.wonID=d.wonID left outer join auction_userwonpaid e on d.paidID=e.paidID   where a.uid=#UID# 
 and a.is_bid=1 and a.pay_status=2  and a.aid in (select aid from auction where asid in (select asid from auction_special where now() > asclosetime) )
 
</cfquery>
<cfreturn paidauctionlist>

</cffunction>
<!---未支付拍品--->
<cffunction access="public" name="unpaidauctionlist" returntype="query">
<cfquery datasource="#DB#" name="unpaidauctionlist">
SELECT
auction_userwon.aid,
auction_userwon.acode,
auction_gallery.img_waterfall,
auction_userwon.auction,
auction.prevtime,
auction.starttime,
auction_userwon.endtime,
auction_userwon.bid_amount AS lastprice,
auction.atag
FROM
auction_userwon
INNER JOIN auction_userwonpaid ON auction_userwonpaid.paidID = auction_userwon.paidID
INNER JOIN auction ON auction.aid = auction_userwon.aid
INNER JOIN auction_gallery ON auction_gallery.agid = auction.agid
WHERE
auction_userwon.uid = #UID# AND
<!---auction.atag > 0 AND--->
auction_userwonpaid.pay_status < 2 AND
auction_userwonpaid.acttime IS NOT NULL
</cfquery>
<cfreturn unpaidauctionlist>

</cffunction>

<!---物流单拍品列表--->
<cffunction access="public" name="shipallwonlist" returntype="query">
<!---暂未加入UUID--->
<cfquery datasource="#DB#" name="shipallwonlist">
SELECT
auction_userwon.aid,
auction_gallery.img_waterfall,
auction_userwon.acode,
auction_userwon.auction,
auction_userwon.endtime,
auction_userwon.limittime,
auction_userwon.bid_amount
FROM
auction_userwon
INNER JOIN auction ON auction.aid = auction_userwon.aid
INNER JOIN auction_gallery ON auction_gallery.agid = auction.agid
ORDER by aID DESC
</cfquery>
<cfreturn shipallwonlist>
</cffunction>

<!---已发货物流单拍品列表--->
<cffunction access="public" name="shipallwonlist12" returntype="query">
<cfquery datasource="#DB#" name="shipallwonlist12">

 select d.aid,f.img_waterfall,d.acode,d.auction,d.endtime,d.limittime,d.bid_amount from auction_userlastbid  a  left outer join auction b on a.aid=b.aid   
 left outer join auction_special c on b.asid=c.asid  left outer join auction_userwon d on a.wonID=d.wonID 
 left outer join auction_userwonpaid e on d.paidID=e.paidID   
 left outer join auction_gallery f ON f.agid = b.agid
 where a.uid=#uid#

 and a.is_bid=1 and a.pay_status=2    and a.aid in (select aid from auction where asid in (select asid from auction_special where now() > asclosetime) )

 and a.aulbid  in (select aulbid from  auction_userwon   where paidID in (select paidID from auction_userwonpaid where pay_status=2 and ship_status=2)  )

order by d.aid desc

</cfquery>
<cfreturn shipallwonlist12>
</cffunction>
<!---未发货物流单拍品列表--->
<cffunction access="public" name="shipallwonlist03" returntype="query">
<cfquery datasource="#DB#" name="shipallwonlist03">
SELECT
auction_userwon.aid,
auction_gallery.img_waterfall,
auction_userwon.acode,
auction_userwon.auction,
auction_userwon.endtime,
auction_userwon.limittime,
auction_userwon.bid_amount
FROM
auction_userwon
INNER JOIN auction ON auction.aid = auction_userwon.aid
INNER JOIN auction_gallery ON auction_gallery.agid = auction.agid
INNER JOIN auction_userwonpaid ON auction_userwonpaid.paidID = auction_userwon.paidID
WHERE auction_userwonpaid.uid = #uid#
AND (ship_status = 0 or ship_status = 3)
<cfif isdefined('attention')>
<cfswitch expression="#attention#">
<cfcase value="1">
AND auction.aid in (#mygzlist#)
</cfcase>
<cfcase value="0">
AND auction.aid not in (#mygzlist#)
</cfcase>
</cfswitch>
</cfif>
ORDER by aID DESC
</cfquery>
<cfreturn shipallwonlist03>
</cffunction>




</cfcomponent>